fix(ui): keep unread badges, mention toggles, and pending switches across a channel rename - #86
Open
Lafnaps wants to merge 1 commit into
Open
fix(ui): keep unread badges, mention toggles, and pending switches across a channel rename#86Lafnaps wants to merge 1 commit into
Lafnaps wants to merge 1 commit into
Conversation
…ross a channel rename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rename a channel that has unread messages and its badge disappears. Reproducible on current main: let #foo accumulate unreads while you sit in #general, rename it to #bar from the tab — the badge is gone although the messages are still unread.
The
channel_renamedhandler in chat.js migrates DOMdata-channelattributes,lastMessageDates, andactiveChannel, but four pieces of state stay keyed under the old name:channelUnread(the count survives, invisible, under a key nothing reads anymore),_channelMentions(the per-channel mention toggle silently resets),channelList, andpendingChannelSwitch(a queued switch to the old name can never match again). The settings frame that accompanies a rename replaceschannelListeventually, but it can't migrate unread/mention state it knows nothing about.The handler now rekeys all four, retargets a pending switch to the new name so it can still resolve, and finishes with
filterMessagesByChannel()+renderChannelTabs()so the tab re-renders with its migrated badge immediately. No protocol changes, no server changes;?v=bumped for chat.js.There's no JS harness in the repo, so this was verified against a live server with a scripted browser (fresh data dir, one registered agent posting into the renamed channel), running the same scenario on this branch and on main:
foo.Python suite untouched by this change (static/ isn't imported): 81 passed before and after.